package com.hmall.trade.listener;

import com.hmall.trade.service.IOrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.lang.model.type.ExecutableType;

@Component
@RequiredArgsConstructor
public class PayStatusListener {
    private final IOrderService orderService;

    /**
     * 监听订单支付成功消息
     */
    @RabbitListener(
            bindings = @QueueBinding(
                    value = @Queue(value = "mark.order.pay.queue", durable = "trur"),
                    exchange = @Exchange(value = "pay.topic",type = ExchangeTypes.TOPIC,durable = "true"),
                    key = {"pay.success"}
            )
    )
    public void  listenPaySuccessMsg(Long orderId){
        orderService.markOrderPaySuccess(orderId);
    }
}
